import json

import requests

from queryItem import queryItem


class str:
    def str(self,CODE,NAME,ITEM_ID,TYPE):
        with open('cookie.json', 'r', encoding='utf-8') as f:
            headers = json.load(f)

        params = {
            'method': 'saveBatchNotSq',
        }

        data = {"items":[
            {"CODE":f"{CODE}"
                             ,"NAME":f"{NAME}"
                             ,"ITEM_ID":f"{ITEM_ID}",
                          "TYPE":f"{TYPE}",
                          "ORG_CODE":"52033020170320131510002391",
                          "ORG_NAME":"习水县民化镇人民政府",
                          "REGION_CODE":"52033005",
                          "REGION_NAME":"习水县民化镇"}],
                "notSqReason":"习水民化联系取消授权",
                "shouquanFileName":"（习水县民化镇）贵州政务服务网需求联系单.pdf",
                "shouquanFileId":"20251114be1013b2-0554-44d6-944b-c528ec336779"
                .format(CODE,NAME,ITEM_ID,TYPE)}

        response = requests.post(
            'http://59.215.206.188/sxgl/mng/shouquan/itemsq',
            params=params,

            headers=headers,
            json=data,
        )
        print(response.json())

    def que(self):
        i=queryItem().query()


        for item in i['rows']:

            CODE=item['cell']['CODE']
            NAME=item['cell']['NAME']
            ITEM_ID=item['cell']['ID']
            TYPE=item['cell']['TYPE']
            self.str(CODE,NAME,ITEM_ID,TYPE)




str().que()